import React from "react"
import { Outlet } from "react-router-dom";
import Index from "../pages/index";
import About from "../pages/about";
import User from "../pages/user";
import ToLogin from "../pages/to-login";
import Notfound from "../pages/notfound";
import Child from "../pages/child";

// !最新react-router-dom 删除了Switch改用Routes替换
// 改造配置才能拿到组件
export default [
  {
    path: "/",
    element: <div>
      <Index />
      <Outlet />
    </div>,
    loadData: Index.loadData,
    key: 'index',
    // 嵌套路由
    children: [
      {
        path: "/child",
        key: 'child',
        element: <Child />
      }
    ]
  },
  {
    path: "/about",
    element: <About />,
    loadData: About.loadData,
    exact: true,
    key: 'about'
  },
  {
    path: "/user",
    element: <User />,
    exact: true,
    key: 'user',
    loadData: User.loadData,
  },
  {
    path: "/to-login",
    element: <ToLogin />,
    exact: true,
    key: 'to-login'
  },
  {
    // todo react-router-dom  最新修改404 路由path:"*"
    path: '*',
    element: <Notfound />,
    key: "notfound"
  }
]
